apply plugin: 'java'
apply plugin: 'war'

sourceCompatibility = 1.7
targetCompatibility = 1.7


repositories {
	mavenCentral()
}

dependencies { 

	providedCompile fileTree(dir: 'src/main/webapp/WEB-INF/lib', include: '*.jar')
	
	providedCompile 'com.google.gwt:gwt-user:2.5.1'
	providedCompile 'com.google.gwt:gwt-servlet:2.5.1'
	providedCompile 'com.google.gwt:gwt-dev:2.5.1'
	providedCompile project.ext["libs"]
	
	providedCompile project(':SmartEagleEJB')
	
	compile('javax.validation:validation-api:1.0.0.GA') {
		artifact {
			name = 'validation-api'
			type = 'jar'
		}
		artifact {
			name = 'validation-api'
			type = 'jar'
			classifier = 'sources'
		}
	}
	
	
	runtime 'com.google.gwt:gwt-servlet:2.5.1'
}


task compileGwt (dependsOn: classes, type: JavaExec) {
	
	ext.buildDir = "${project.buildDir}/gwt"

	inputs.source sourceSets.main.java.srcDirs
	inputs.dir sourceSets.main.output.resourcesDir
	outputs.dir buildDir

	outputs.upToDateSpec = new org.gradle.api.specs.AndSpec()
	 
	doFirst {
		file(buildDir).mkdirs()
	}

	main = 'com.google.gwt.dev.Compiler'

	classpath {
		[
			sourceSets.main.java.srcDirs,           // Java source
			sourceSets.main.output.resourcesDir,    // Generated resources
			sourceSets.main.output.classesDir,      // Generated classes
			sourceSets.main.compileClasspath,       // Deps
			project(':SmartEagleEJB').sourceSets.main.java.srcDirs,
			project(':SmartEagleEJB').sourceSets.main.output.resourcesDir
		]
	}

	args =
		[
			'co.com.smart.eagle.SmartEagle',
			'co.com.smart.login.Login',
			'-war', buildDir,
			'-strict'
		]

	maxHeapSize = '1024M'
	//jvmArgs '-Xmx2048m'
	
}

tasks.withType(Compile) {
    options.encoding = 'iso-8859-1'
}

war.dependsOn compileGwt
war {
	from compileGwt.buildDir
}